package com.example.news.helper;

import android.content.Context;
import android.media.MediaPlayer;

import com.example.news.R;
import com.example.news.activity.LoginActivity;

public class Mp3helper {
   public MediaPlayer mediaPlayer;
   public Context context;
   public int raw;
   public Mp3helper(Context context, int raw){
      this.context=context;
      this.raw=raw;
      this.mediaPlayer=MediaPlayer.create(this.context, raw);

   }
   public void play(boolean bool)
   {
      mediaPlayer.setLooping(bool);
      //设置播放起始点
      mediaPlayer.seekTo(0);
      //开始播放
      mediaPlayer.start();
   }
   public void stop()
   {
      mediaPlayer.stop();
      //释放资源
      mediaPlayer.release();
      mediaPlayer=null;
   }
}
